home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 1 / ETO Development Tools 1.iso / Essentials / MacApp Documentation / MacApp AppleLink Messages / MacApp.Tech$ Oct 89 / Z0016-Re DoRead, DoWrite -Oct89 < prev    next >
Encoding:
Text File  |  1989-10-05  |  1.3 KB  |  44 lines  |  [TEXT/GEOL]

  1. Item    6889457                         5-Oct-89        10:19
  2.  
  3. From:   KNEPPER                         Knepper, Christopher
  4.  
  5. To:     LANGSTON1                       Langston, Jeff,CLA
  6.  
  7. cc:     MACAPP.TECH$                    MACAPP Tech
  8.  
  9. Sub:    Re: DoRead, DoWrite request
  10.  
  11. Phil,
  12.  
  13. In response to your enhancement request:
  14.  
  15. >My request is that both DoRead and DoWrite have the resource fork reference
  16. >number passed in.
  17.  
  18. I disagree. I don't think that either DoRead or DoWrite should pass in the ref
  19. num of the res fork. The reason I disagree is that you don't need it. As long
  20. as you call IDocument "correctly" from I<your app>Document, the resource fork
  21. of the file will be open when DoRead or DoWrite are called:
  22.  
  23.  IDocument(kFileType, kSignature, kUsesDataFork, kUsesRsrcFork, kDataOpen,
  24. kRsrcOpen);
  25.  
  26. Here's some code that I use in my DoWrite to add a resource to the file:
  27.  
  28.  { since the resource fork is open, I can add a resource }
  29.    h := CreateViewRsrcHandle(fMyView);
  30.    FailNIL(h);
  31.    AddResource(h, 'view', kMyID, 'MyView');
  32.    FailResError;
  33.    SetResAttrs(h,resPurgeable);
  34.    ChangedResource(h);
  35.    WriteResource(h);
  36.    UpdateResFile(fRsrcRefnum);
  37.  
  38. Note that "CreateViewRsrcHandle" is a nifty routine developed by Joost Kemink
  39. that takes a handle to a TView object (or a subclass of TView) and returns a
  40. handle to a 'view' resource.
  41.  
  42. -Chris
  43.  
  44.